from rest_framework.decorators import api_view
from rest_framework.request import Request
from rest_framework.response import Response

from api.serializers.pay_method_serializer import PayMethodSerializer
from app.models.pay_method import PayMethod


@api_view(['GET'])
def get_pay_method(request: Request):
    pay_methods = PayMethod.objects.all().order_by('priority').reverse()
    serializer = PayMethodSerializer(list(pay_methods), many=True)
    return Response(serializer.data)
